<?php
namespace Club\Controller;
use Think\Controller;

class CustomizedTravelController extends \Org\Util\AdminController {

	/**
	 * 权限验证标志位,默认false
	 * false:所有action都需要权限验证;
	 * true:所有action都不需要权限验证;
	 * array:array中的action不需要权限验证，其余需要。
	 */
	protected $notAuthority = false;

	/**
	 * 创建之后做的事情
	 */
	public function interfaceAfterCreate($id) {
	}

	/**
	 * 删除之前做的事情
	 */
	public function interfaceBeforeDelete($id) {
	}

	/**
	 * 更新之前做的事情
	 */
	public function interfaceBeforeUpdate($id) {
	}

	/**
	 * 父类中已经有典型的CRUD操作并预留入口
	 * 如有较大改动则覆盖一下
	 */
	public function create() {
		parent::create();
	}

	public function delete() {
		parent::delete();
	}

	public function update($id) {
		parent::update($id);
	}

	public function list() {
		//获取旅社信息
		$club = D('UserClub')->where(['principal_id' => session('旅社')['id']])->find();
		$time = time()-60;
		$_GET['searchMap']['_string'] = '(state = "待处理" AND type IN (' . $club['bussiness'] . ') AND region_id =' . $club['service_area'] . ' AND create_time < '.$time.') OR (state = "已处理" AND club_user_id = ' . session('旅社')['id'] . ')';
		parent::list();
	}

	public function detail($id = 0) {
		parent::detail($id);
	}

	public function import() {
		parent::import();
	}

	public function export() {
		parent::export();
	}

	public function tableOpeationButton() {
		return '
            <if condition="$vo[\'state\'] eq \'待处理\'">
                <a href="__MODULE__/Funding/create/funding_type/{$vo[\'type\']}/transaction_type/{$vo[\'transaction_type\']}/customized_id/{$vo[\'id\']}" onclick="return confirm(\'是否确认处理该订单?\');">
                    <button class="btn btn-xs btn-primary" style="border: 1px;">
                        <i class="icon-edit" style="margin-right: 0px;"></i>
                    </button>
                </a>
            <else/>
                <a href="__MODULE__/Funding/update/id/{$vo[\'funding_id\']}">
                    <button class="btn btn-xs btn-primary" style="border: 1px;">
                        <i class="icon-edit" style="margin-right: 0px;"></i>
                    </button>
                </a>
            </if>
            ';
	}

	public function wapTableOpeationButton() {
		return '
                                            <li>
                                                <a href="__ROOT__/Home/Index/call/id1/' . session('旅社')['id'] . '/id2/{$vo[\'user_id\']}" class="tooltip-success" data-rel="tooltip">
                                                    <span class="green">
                                                        <i class="icon-phone bigger-120"></i>
                                                    </span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="__MODULE__/Funding/create/funding_type/{$vo[\'type\']}/transaction_type/定制" onclick="return confirm(\'是否确认处理该订单?\');" class="tooltip-primary" data-rel="tooltip">
                                                    <span class="green">
                                                        <i class="icon-edit bigger-120"></i>
                                                    </span>
                                                </a>
                                            </li>';
	}
}
